using System;
using System.Collections;
using System.Text;
using System.Windows.Forms;

namespace OurMediaPlayer.Logic
{
    public class MediaManager
    {
        public MediaManager()
        {
            this.videos = new Hashtable();
        }

        public void AddVideo(Media video, string filename)
        {
            if(!this.videos.Contains(filename))
                this.videos.Add(filename, video);
        }

        public Media GetVideo(String filename)
        {
            return (Media)videos[filename];
        }

        public void CloseCurrentVideo()
        {
            // If there's one video currently playing
            if (this.currentMedia != null)
            {
                // File name changed, close the old file
                this.currentMedia.Stop();
                this.currentMedia.Dispose();
                this.currentMedia = null;
            }
        }

        public void RemoveVideo(string filename)
        {
            Media video = this.GetVideo(filename);
            video.Dispose();
            video = null;

            this.videos.Remove(filename);
        }

        public void SetCurrentVideo(string filename)
        {
            this.currentMedia = (Media)videos[filename];
        }

        public void Clear()
        {
            this.videos.Clear();
        }

        public Media currentMedia;

        public Hashtable videos;
    }
}
